package cn.tx.demo;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author Mxb
 * @version 1.0
 * @date 2020/10/16 19:17
 */
public class Demo {
    public static void main(String[] args) throws UnknownHostException {
        //InetAddress address = InetAddress.getByName("itheima");
        InetAddress address = InetAddress.getByName("192.168.1.66");
        //public String getHostName()：获取此IP地址的主机名
        String name = address.getHostName();
        //public String getHostAddress()：返回文本显示中的IP地址字符串
        String ip = address.getHostAddress();
        System.out.println("主机名：" + name);
        System.out.println("IP地址：" + ip);
    }
}
